﻿//-----------------------------------------------------------------------
// <copyright file="DialogService.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP.ViewModels.Dialogs
{
    using System.Windows;

    using Microsoft.Win32;

    /// <summary>
    /// Implements methods to work with message and dialog boxes
    /// </summary>
    public class DialogService : IDialogService
    {
        /// <summary>
        /// Shows message of specific type in a message box
        /// </summary>
        /// <param name="message">Message to be shown</param>
        /// <param name="messageType">Message's type</param>
        public void ShowMessage(string message, MessageType messageType)
        {
            if (messageType == MessageType.INFO)
            {
                MessageBox.Show(message, "PLANA", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (messageType == MessageType.WARNING)
            {
                MessageBox.Show(message, "PLANA", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                MessageBox.Show(message, "PLANA", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        /// <summary>
        /// Asks user for confirmation
        /// </summary>
        /// <param name="question">Question displayed to the user</param>
        /// <returns>True if user confirms; otherwise false</returns>
        public bool DoesUserConfirms(string question)
        {
            return MessageBox.Show(question, "PLANA", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK;
        }

        /// <summary>
        /// Shows dialog for browsing files
        /// </summary>
        /// <returns>Path of the browsed file</returns>
        public string BrowseFile()
        {
            var dlg = new OpenFileDialog { InitialDirectory = "c:\\", RestoreDirectory = true };
            return dlg.ShowDialog().Value ? dlg.FileName : null;
        }
    }
}
